{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "5559b2f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "ad793894",
   "metadata": {},
   "outputs": [],
   "source": [
    "base_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/create'\n",
    "\n",
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'image_url':'https://tse1-mm.cn.bing.net/th/id/OIP-C.HPWFQ7UDQh93EKcDmiUQ_wHaIR?w=176&h=197&c=7&r=0&o=5&dpr=2&pid=1.7'    \n",
    "}\n",
    "r = requests.post(url = base_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "91e34a85",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "b6039ef7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'c1e23aab518a32fc27717951470ef80a',\n",
       " 'time_used': 153,\n",
       " 'face_count': 0,\n",
       " 'face_added': 0,\n",
       " 'request_id': '1648887499,1b46e78e-1e45-4bf1-b631-003836562d4c',\n",
       " 'outer_id': '',\n",
       " 'failure_detail': []}"
      ]
     },
     "execution_count": 125,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b3116a3",
   "metadata": {},
   "source": [
    "# 人脸识别 实践 宿舍智能识别门禁系统\n",
    "* 1.创建faceset\n",
    "* 2.查询faceset\n",
    "* 3.存入facetoken库\n",
    "* 4.获取faceset信息数据\n",
    "* 5.人脸搜索\n",
    "* 6.人脸对比"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "235ae0f7",
   "metadata": {},
   "source": [
    "## 1."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce7345fe",
   "metadata": {},
   "source": [
    "## 调用url\n",
    ">https://api-cn.faceplusplus.com/facepp/v3/faceset/create\n",
    "## 调用方法\n",
    ">post\n",
    "## 请求参数\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "b24a2814",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "dd054702",
   "metadata": {},
   "outputs": [],
   "source": [
    "facesetget_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/getfacesets'\n",
    "\n",
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'image_url':'https://tse1-mm.cn.bing.net/th/id/OIP-C.HPWFQ7UDQh93EKcDmiUQ_wHaIR?w=176&h=197&c=7&r=0&o=5&dpr=2&pid=1.7'    \n",
    "}\n",
    "r = requests.post(url = facesetget_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "id": "536240de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 129,\n",
       " 'facesets': [{'faceset_token': '3a291dbe91966977c154a62055b2c804',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'a67d7d79c56c97e3b7b533c090c95cc1',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'a256cc88c6178a7a01ad2996f761aeb9',\n",
       "   'outer_id': 'NFSU00',\n",
       "   'display_name': 'qwer',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '0218367b4ba29064ab24b65df6eea1ce',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '9e2de5df02c75f09721c614e27943f0c',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'af87f716c923d0339e5bb6b7909243fd',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '0de33c25c0b8d884e8f57cfcc30255d6',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '40f610a276e3a126fcc345328e079ba1',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'a30c946c22de2fbb7f0e885f1832217e',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '36204b7c1fced95afced5b38c8b43efe',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '2c4848769a45668e13d57d229ee94924',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'fc4b49ac203596f734564a14827d0e1c',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '0a8454712665469bc95dafa19f75d254',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '36445ac06273cde9c1941298710f0dbd',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'b09b3c1bfe07268642e320f3d9d7b578',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '741f5184505a33b2e19c201e609dc678',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'aa9a49997465dfd5ec884fa1ccc6d03e',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '5bcab12a8aecb3a1858510c72b48930d',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '9685c1d2cab322210d7670b9d42e0009',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'c1e23aab518a32fc27717951470ef80a',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''}],\n",
       " 'request_id': '1648887500,ac968f1d-35ae-4407-a8ef-424c88a80ab6'}"
      ]
     },
     "execution_count": 128,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "7ed257a7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "0df792a6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>是否必选</th>\n",
       "      <th>参数名</th>\n",
       "      <th>类型</th>\n",
       "      <th>参数说明</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>必选</td>\n",
       "      <td>api_key</td>\n",
       "      <td>String</td>\n",
       "      <td>调用此 API 的 API Key</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>必选</td>\n",
       "      <td>api_secret</td>\n",
       "      <td>String</td>\n",
       "      <td>调用此 API 的 API Secret</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>可选</td>\n",
       "      <td>display_name</td>\n",
       "      <td>String</td>\n",
       "      <td>人脸集合的名字，最长256个字符，不能包括字符^@,&amp;=*'\"</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>可选</td>\n",
       "      <td>outer_id</td>\n",
       "      <td>String</td>\n",
       "      <td>账号下全局唯一的 FaceSet 自定义标识，可以用来管理 FaceSet 对象。最长255...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>可选</td>\n",
       "      <td>tags</td>\n",
       "      <td>String</td>\n",
       "      <td>FaceSet 自定义标签组成的字符串，用来对 FaceSet 分组。最长255个字符，多个...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>可选</td>\n",
       "      <td>face_tokens</td>\n",
       "      <td>String</td>\n",
       "      <td>人脸标识 face_token，可以是一个或者多个，用逗号分隔。最多不超过5个 face_t...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>可选</td>\n",
       "      <td>user_data</td>\n",
       "      <td>String</td>\n",
       "      <td>自定义用户信息，不大于16 KB，不能包括字符^@,&amp;=*'\"</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>可选</td>\n",
       "      <td>force_merge</td>\n",
       "      <td>Int</td>\n",
       "      <td>在传入 outer_id 的情况下，如果 outer_id 已经存在，是否将 face_to...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  是否必选           参数名      类型  \\\n",
       "0   必选       api_key  String   \n",
       "1   必选    api_secret  String   \n",
       "2   可选  display_name  String   \n",
       "3   可选      outer_id  String   \n",
       "4   可选          tags  String   \n",
       "5   可选   face_tokens  String   \n",
       "6   可选     user_data  String   \n",
       "7   可选   force_merge     Int   \n",
       "\n",
       "                                                参数说明  \n",
       "0                                  调用此 API 的 API Key  \n",
       "1                               调用此 API 的 API Secret  \n",
       "2                    人脸集合的名字，最长256个字符，不能包括字符^@,&=*'\"  \n",
       "3  账号下全局唯一的 FaceSet 自定义标识，可以用来管理 FaceSet 对象。最长255...  \n",
       "4  FaceSet 自定义标签组成的字符串，用来对 FaceSet 分组。最长255个字符，多个...  \n",
       "5  人脸标识 face_token，可以是一个或者多个，用逗号分隔。最多不超过5个 face_t...  \n",
       "6                    自定义用户信息，不大于16 KB，不能包括字符^@,&=*'\"  \n",
       "7  在传入 outer_id 的情况下，如果 outer_id 已经存在，是否将 face_to...  "
      ]
     },
     "execution_count": 130,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"\"\"<div class=\"table-wrap\"><table class=\"wrapped confluenceTable\"><colgroup><col><col><col><col></colgroup><tbody><tr><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">是否必选</span></p></th><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">参数名</span></p></th><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">类型</span></p></th><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">参数说明</span></p></th></tr><tr><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">必选</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">api_key</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">String</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">调用此 API 的 API Key</span></p></td></tr><tr><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">必选</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">api_secret</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">String</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">调用此 API 的 API Secret</span></p></td></tr><tr><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">display_name</span></td><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">人脸集合的名字，最长<span class=\"inline-comment-marker\" data-ref=\"9f098728-ac30-41a2-aab6-05b79f8a7d2e\">256</span>个字符，不能包括字符^@,&=*'\"</span></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">outer_id</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">账号下全局唯一的 FaceSet 自定义标识，可以用来管理 FaceSet 对象。最长255个字符，<span class=\"inline-comment-marker\" data-ref=\"63fc0fd1-cd44-4256-bab5-971a939d66e2\"><span class=\"inline-comment-marker\" data-ref=\"183dcb11-c22c-47f4-aa9c-2ba6f3c8210c\">不能包括字符^@,&=*'\"</span></span></span></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">tags</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">FaceSet 自定义标签组成的字符串，用来对 FaceSet 分组。最长<span class=\"inline-comment-marker\" data-ref=\"1be760b6-f20d-4ff3-a086-b7f763abd84d\">255</span>个字符，多个 tag 用逗号分隔，每个 tag 不能包括字符^@,&=*'\"</span></td></tr><tr><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">可选</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">face_tokens</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">String</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">人脸标识 face_token，可以是一个或者多个，用逗号分隔。最多不超过5个 face_token</span></p></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">user_data</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">自定义用户信息，不大于<span class=\"inline-comment-marker\" data-ref=\"f9edadb1-691d-4d80-933e-909096780f61\">16 KB，不能包括字符^@,&=*'\"</span></span></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">force_merge</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">Int</span></td><td colspan=\"1\" class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">在传入 outer_id 的情况下，如果 outer_id 已经存在，是否将 face_token 加入已经存在的 FaceSet 中</span></p><p><span style=\"color: rgb(0,0,0);\">0：不将 face_tokens 加入已存在的 FaceSet 中，直接返回 FACESET_EXIST 错误</span></p><p><span style=\"color: rgb(0,0,0);\">1：将 face_tokens 加入已存在的 FaceSet 中</span></p><p><span style=\"color: rgb(0,0,0);\">默认值为0</span></p></td></tr></tbody></table></div>\"\"\")[0]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6c2c0e04",
   "metadata": {},
   "source": [
    "## 创建 create"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "6c9d75ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "# A-1 创建人脸数据集合\n",
    "faceSetcreate_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/create\"\n",
    "\n",
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'\n",
    "payload = {\n",
    "    \"api_key\":API_key,\n",
    "    \"api_secret\":API_sercret\n",
    "}\n",
    "r = requests.post(url = faceSetcreate_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "id": "12ab3e89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 132,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "03798819",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method Response.json of <Response [200]>>"
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f273e01",
   "metadata": {},
   "source": [
    "## 查询"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fefebf5d",
   "metadata": {},
   "source": [
    "## 更新数据集 人脸库api"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "id": "fedfd27d",
   "metadata": {},
   "outputs": [],
   "source": [
    "facesetupdate_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/update'\n",
    "\n",
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'display_name':'qwer',\n",
    "    'outer_id':'NFSU00',\n",
    "    'user_data':'6层，满员，女生宿舍，450位同学'\n",
    "    \n",
    "    \n",
    "}\n",
    "r = requests.post(url = facesetupdate_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "id": "429d974b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 135,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "1352c36e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'a256cc88c6178a7a01ad2996f761aeb9',\n",
       " 'request_id': '1648887502,43c72c62-901b-4b15-93ad-4ae97dd76999',\n",
       " 'time_used': 80,\n",
       " 'outer_id': 'NFSU00'}"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "a15df2ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "facesetgetdetail_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail'\n",
    "\n",
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'display_name':'qwer',\n",
    "    'outer_id':'NFSU00',\n",
    "    'user_data':'6层，满员，女生宿舍，450位同学'\n",
    "    \n",
    "    \n",
    "}\n",
    "r = requests.post(url = facesetgetdetail_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "849308d2",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'a256cc88c6178a7a01ad2996f761aeb9',\n",
       " 'tags': '',\n",
       " 'time_used': 98,\n",
       " 'user_data': '6层，满员，女生宿舍，450位同学',\n",
       " 'display_name': 'qwer',\n",
       " 'face_tokens': ['ecfd0ab094dea35e1ffe7c39151b4bb4'],\n",
       " 'face_count': 1,\n",
       " 'request_id': '1648887503,8cff0a05-c1e0-45f8-84a0-016887c87b7a',\n",
       " 'outer_id': 'NFSU00'}"
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "77fb59d4",
   "metadata": {},
   "source": [
    "## 获取所有 faceset 数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "1ecc1d00",
   "metadata": {},
   "outputs": [],
   "source": [
    "getfacesets_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/getfacesets\"\n",
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "}\n",
    "r = requests.post(url = getfacesets_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "bb3b6c33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 110,\n",
       " 'facesets': [{'faceset_token': '3a291dbe91966977c154a62055b2c804',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'a67d7d79c56c97e3b7b533c090c95cc1',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'a256cc88c6178a7a01ad2996f761aeb9',\n",
       "   'outer_id': 'NFSU00',\n",
       "   'display_name': 'qwer',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '0218367b4ba29064ab24b65df6eea1ce',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '9e2de5df02c75f09721c614e27943f0c',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'af87f716c923d0339e5bb6b7909243fd',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '0de33c25c0b8d884e8f57cfcc30255d6',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '40f610a276e3a126fcc345328e079ba1',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'a30c946c22de2fbb7f0e885f1832217e',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '36204b7c1fced95afced5b38c8b43efe',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '2c4848769a45668e13d57d229ee94924',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'fc4b49ac203596f734564a14827d0e1c',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '0a8454712665469bc95dafa19f75d254',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '36445ac06273cde9c1941298710f0dbd',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'b09b3c1bfe07268642e320f3d9d7b578',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '741f5184505a33b2e19c201e609dc678',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'aa9a49997465dfd5ec884fa1ccc6d03e',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '5bcab12a8aecb3a1858510c72b48930d',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '9685c1d2cab322210d7670b9d42e0009',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'c1e23aab518a32fc27717951470ef80a',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'abc2229097e69eaf059ec3e9c54ec1a8',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''}],\n",
       " 'request_id': '1648887503,882b60e9-3692-4002-b825-a1e791db7a23'}"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19a91c29",
   "metadata": {},
   "source": [
    "## 6.人脸存放"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "id": "2c86f4e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887504,3cf5da0c-b942-4140-b88e-08da80163949',\n",
       " 'time_used': 95,\n",
       " 'faces': [{'face_token': '068feb5ca86f060a0219d0607aafd478',\n",
       "   'face_rectangle': {'top': 98, 'left': 164, 'width': 118, 'height': 118}}],\n",
       " 'image_id': '3XXAy6wuwDnc0I+ASLvc3Q==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "detect.face_detect(API_key, API_sercret,'Liu_01.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "id": "671c2874",
   "metadata": {},
   "outputs": [],
   "source": [
    "facesetaddface_url = ' https://api-cn.faceplusplus.com/facepp/v3/faceset/addface'\n",
    "\n",
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'outer_id': 'NFSU00',\n",
    "    'face_tokens': 'ecfd0ab094dea35e1ffe7c39151b4bb4'\n",
    "}   \n",
    "r = requests.post(url = facesetaddface_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "id": "9f3408bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'a256cc88c6178a7a01ad2996f761aeb9',\n",
       " 'time_used': 108,\n",
       " 'face_count': 1,\n",
       " 'face_added': 0,\n",
       " 'request_id': '1648887504,3f04292f-3676-4b88-9948-c01f9afe00fe',\n",
       " 'outer_id': 'NFSU00',\n",
       " 'failure_detail': []}"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c7fc5ab5",
   "metadata": {},
   "source": [
    "# 作业部分 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6db6ad61",
   "metadata": {},
   "source": [
    "## 准备环节  取两个刘德华的face_token 人脸检测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "947d3ddb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887505,b9d2b1f2-1d25-42a4-9bc7-d3e1edc8ae6c',\n",
       " 'time_used': 51,\n",
       " 'faces': [{'face_token': '2ce220dfd01daa6c1519f6caaad19510',\n",
       "   'face_rectangle': {'top': 98, 'left': 164, 'width': 118, 'height': 118}}],\n",
       " 'image_id': '3XXAy6wuwDnc0I+ASLvc3Q==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "detect.face_detect(API_key, API_sercret,'Liu_01.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "16a90bdf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887505,49cbbd8e-c26b-4af7-bdb9-55e9f33757fa',\n",
       " 'time_used': 57,\n",
       " 'faces': [{'face_token': '60149f637be43ed000639c86b621d0f8',\n",
       "   'face_rectangle': {'top': 62, 'left': 140, 'width': 81, 'height': 81}}],\n",
       " 'image_id': 'uwuFcFPPfmsroBMHTKhxUA==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "detect.face_detect(API_key, API_sercret,'Liu_02.jpeg')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0671c069",
   "metadata": {},
   "source": [
    "## 设置账号密码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "id": "eefaa674",
   "metadata": {},
   "outputs": [],
   "source": [
    "API_key = '6xKBdXQ2sBK_6-zGz07celvGSt0KLF7g'\n",
    "API_sercret = 'z1miz-HzEsakvANm8oIij8xeoo4DHeDs'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "444cee63",
   "metadata": {},
   "source": [
    "## 作业1 调用detect"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68f65369",
   "metadata": {},
   "source": [
    "## 调用  detect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "7d017669",
   "metadata": {},
   "outputs": [],
   "source": [
    "import detect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "de2bd4aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887506,48ed0796-fbd7-45c0-9f3b-4b4bc5a58d08',\n",
       " 'time_used': 86,\n",
       " 'faces': [{'face_token': '7d9137e9fc1b149acb231bc280b3c6f8',\n",
       "   'face_rectangle': {'top': 98, 'left': 164, 'width': 118, 'height': 118}}],\n",
       " 'image_id': '3XXAy6wuwDnc0I+ASLvc3Q==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "detect.face_detect(API_key, API_sercret,'Liu_01.png')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2111c4b9",
   "metadata": {},
   "source": [
    "## 作业2 调用其他"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6de13ef9",
   "metadata": {},
   "source": [
    "## 调用analyze"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "id": "e8cd4533",
   "metadata": {},
   "outputs": [],
   "source": [
    "import analyze"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "id": "fe233634",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 82,\n",
       " 'request_id': '1648887507,b406510a-db14-4b66-a453-2987a56b23ad',\n",
       " 'faces': [{'landmark': {'mouth_upper_lip_left_contour2': {'y': 175, 'x': 197},\n",
       "    'mouth_upper_lip_top': {'y': 172, 'x': 212},\n",
       "    'mouth_upper_lip_left_contour1': {'y': 172, 'x': 206},\n",
       "    'left_eye_upper_left_quarter': {'y': 123, 'x': 179},\n",
       "    'left_eyebrow_lower_middle': {'y': 111, 'x': 180},\n",
       "    'mouth_upper_lip_left_contour3': {'y': 177, 'x': 201},\n",
       "    'left_eyebrow_lower_left_quarter': {'y': 113, 'x': 173},\n",
       "    'left_eye_bottom': {'y': 127, 'x': 185},\n",
       "    'right_eyebrow_lower_left_quarter': {'y': 105, 'x': 230},\n",
       "    'nose_contour_left1': {'y': 124, 'x': 201},\n",
       "    'mouth_lower_lip_right_contour1': {'y': 179, 'x': 228},\n",
       "    'mouth_lower_lip_left_contour2': {'y': 185, 'x': 196},\n",
       "    'mouth_lower_lip_left_contour3': {'y': 188, 'x': 204},\n",
       "    'mouth_lower_lip_bottom': {'y': 188, 'x': 215},\n",
       "    'contour_chin': {'y': 219, 'x': 218},\n",
       "    'contour_left9': {'y': 216, 'x': 204},\n",
       "    'mouth_lower_lip_top': {'y': 183, 'x': 214},\n",
       "    'right_eyebrow_upper_middle': {'y': 98, 'x': 239},\n",
       "    'left_eyebrow_left_corner': {'y': 115, 'x': 166},\n",
       "    'contour_left6': {'y': 189, 'x': 177},\n",
       "    'right_eye_lower_right_quarter': {'y': 120, 'x': 243},\n",
       "    'right_eye_bottom': {'y': 121, 'x': 237},\n",
       "    'contour_left7': {'y': 200, 'x': 184},\n",
       "    'contour_right8': {'y': 208, 'x': 248},\n",
       "    'contour_left5': {'y': 178, 'x': 171},\n",
       "    'contour_left4': {'y': 166, 'x': 167},\n",
       "    'contour_left3': {'y': 153, 'x': 165},\n",
       "    'contour_left2': {'y': 141, 'x': 164},\n",
       "    'contour_left1': {'y': 129, 'x': 164},\n",
       "    'left_eye_lower_left_quarter': {'y': 127, 'x': 180},\n",
       "    'contour_right1': {'y': 118, 'x': 276},\n",
       "    'right_eye_pupil': {'y': 118, 'x': 237},\n",
       "    'contour_right2': {'y': 132, 'x': 277},\n",
       "    'mouth_left_corner': {'y': 180, 'x': 190},\n",
       "    'contour_right4': {'y': 160, 'x': 277},\n",
       "    'contour_right7': {'y': 198, 'x': 259},\n",
       "    'contour_left8': {'y': 209, 'x': 193},\n",
       "    'nose_right': {'y': 152, 'x': 229},\n",
       "    'right_eye_upper_right_quarter': {'y': 115, 'x': 243},\n",
       "    'nose_tip': {'y': 152, 'x': 207},\n",
       "    'contour_right5': {'y': 174, 'x': 274},\n",
       "    'nose_contour_lower_middle': {'y': 161, 'x': 210},\n",
       "    'right_eye_top': {'y': 115, 'x': 236},\n",
       "    'right_eye_right_corner': {'y': 118, 'x': 248},\n",
       "    'mouth_upper_lip_right_contour1': {'y': 171, 'x': 218},\n",
       "    'mouth_upper_lip_right_contour2': {'y': 171, 'x': 230},\n",
       "    'right_eyebrow_lower_right_quarter': {'y': 105, 'x': 248},\n",
       "    'contour_right9': {'y': 215, 'x': 234},\n",
       "    'mouth_right_corner': {'y': 173, 'x': 242},\n",
       "    'right_eye_lower_left_quarter': {'y': 121, 'x': 232},\n",
       "    'left_eyebrow_right_corner': {'y': 109, 'x': 196},\n",
       "    'left_eyebrow_lower_right_quarter': {'y': 111, 'x': 188},\n",
       "    'right_eye_center': {'y': 119, 'x': 237},\n",
       "    'left_eye_pupil': {'y': 124, 'x': 185},\n",
       "    'left_eye_upper_right_quarter': {'y': 122, 'x': 190},\n",
       "    'nose_left': {'y': 154, 'x': 193},\n",
       "    'right_eyebrow_lower_middle': {'y': 104, 'x': 239},\n",
       "    'left_eye_center': {'y': 124, 'x': 185},\n",
       "    'left_eye_lower_right_quarter': {'y': 126, 'x': 190},\n",
       "    'right_eyebrow_left_corner': {'y': 105, 'x': 220},\n",
       "    'right_eye_left_corner': {'y': 120, 'x': 226},\n",
       "    'left_eyebrow_upper_left_quarter': {'y': 109, 'x': 172},\n",
       "    'left_eye_left_corner': {'y': 126, 'x': 175},\n",
       "    'left_eye_right_corner': {'y': 124, 'x': 194},\n",
       "    'right_eyebrow_upper_left_quarter': {'y': 99, 'x': 229},\n",
       "    'right_eyebrow_right_corner': {'y': 106, 'x': 256},\n",
       "    'right_eye_upper_left_quarter': {'y': 116, 'x': 231},\n",
       "    'left_eyebrow_upper_middle': {'y': 106, 'x': 180},\n",
       "    'right_eyebrow_upper_right_quarter': {'y': 99, 'x': 249},\n",
       "    'mouth_lower_lip_right_contour3': {'y': 185, 'x': 226},\n",
       "    'nose_contour_left2': {'y': 145, 'x': 196},\n",
       "    'nose_contour_left3': {'y': 159, 'x': 201},\n",
       "    'nose_contour_right1': {'y': 122, 'x': 219},\n",
       "    'nose_contour_right2': {'y': 143, 'x': 224},\n",
       "    'mouth_lower_lip_right_contour2': {'y': 180, 'x': 235},\n",
       "    'mouth_upper_lip_bottom': {'y': 176, 'x': 213},\n",
       "    'contour_right6': {'y': 187, 'x': 268},\n",
       "    'nose_contour_right3': {'y': 157, 'x': 220},\n",
       "    'left_eye_top': {'y': 121, 'x': 184},\n",
       "    'mouth_upper_lip_right_contour3': {'y': 174, 'x': 227},\n",
       "    'left_eyebrow_upper_right_quarter': {'y': 106, 'x': 188},\n",
       "    'contour_right3': {'y': 146, 'x': 278},\n",
       "    'mouth_lower_lip_left_contour1': {'y': 183, 'x': 201}},\n",
       "   'face_rectangle': {'width': 118, 'top': 98, 'left': 164, 'height': 118},\n",
       "   'face_token': 'a353cfa5b97bf42d562121edc21c7065'}]}"
      ]
     },
     "execution_count": 150,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analyze.face_analyze(API_key,API_sercret,'a353cfa5b97bf42d562121edc21c7065',attributes=None,landmark=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "id": "a0c5c8e9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'a256cc88c6178a7a01ad2996f761aeb9',\n",
       " 'time_used': 108,\n",
       " 'face_count': 1,\n",
       " 'face_added': 0,\n",
       " 'request_id': '1648887504,3f04292f-3676-4b88-9948-c01f9afe00fe',\n",
       " 'outer_id': 'NFSU00',\n",
       " 'failure_detail': []}"
      ]
     },
     "execution_count": 151,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04edbea0",
   "metadata": {},
   "source": [
    "##  调用search 搜索"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "fcc8f1b0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import search"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "84c9b217",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887507,305303bd-6333-4670-b91f-18a8de9fc7e7',\n",
       " 'time_used': 340,\n",
       " 'thresholds': {'1e-3': 62.327, '1e-5': 73.975, '1e-4': 69.101},\n",
       " 'results': [{'confidence': 97.389,\n",
       "   'user_id': '',\n",
       "   'face_token': 'ecfd0ab094dea35e1ffe7c39151b4bb4'}]}"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "search.face_search(API_key,API_sercret,'NFSU00','a353cfa5b97bf42d562121edc21c7065')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d3915f6e",
   "metadata": {},
   "source": [
    "##  调用compare 比较  此处还是用刘德华"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "id": "81866608",
   "metadata": {},
   "outputs": [],
   "source": [
    "import compare"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "id": "3af91eec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887508,2ce836a4-4427-4810-a4c6-dd483335103d',\n",
       " 'time_used': 317,\n",
       " 'confidence': 91.665,\n",
       " 'thresholds': {'1e-3': 62.327, '1e-4': 69.101, '1e-5': 73.975}}"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "compare.face_compare(API_key,API_sercret,'e4f4caef0bf0d5120608394f0b50848c','25ae9ef6ae5eea947b092699133aa6df')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6708c69c",
   "metadata": {},
   "source": [
    "##  作业3 存入宿舍数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e269e8c",
   "metadata": {},
   "source": [
    "## 分析自己上传的人脸照片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "id": "d67bd98d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887509,9395df2d-c86b-4ba9-bf1b-b770a3603d95',\n",
       " 'time_used': 163,\n",
       " 'faces': [{'face_token': '87246116c25f90e208b5d4d8dc375ffd',\n",
       "   'face_rectangle': {'top': 561, 'left': 333, 'width': 385, 'height': 385}}],\n",
       " 'image_id': 'aDVFuWTJ9UnWPTWpzggUBA==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "detect.face_detect(API_key, API_sercret,'wy.jpg')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5819e144",
   "metadata": {},
   "source": [
    "## 对比  刘德华"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "id": "46f9c8a4",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648887509,13513cb4-8f8c-4af2-b144-7d2ad7a1401c',\n",
       " 'time_used': 496,\n",
       " 'confidence': 15.495,\n",
       " 'thresholds': {'1e-3': 62.327, '1e-4': 69.101, '1e-5': 73.975}}"
      ]
     },
     "execution_count": 157,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "compare.face_compare(API_key,API_sercret,'71b0dbe85a222540f72b7bf9bf1d9a74','25ae9ef6ae5eea947b092699133aa6df')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "921b677f",
   "metadata": {},
   "source": [
    "## 比对成功 识别出不是一个人"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
